/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NAPI_CAST_ENGINE_DLNA_SERVICE_H
#define NAPI_CAST_ENGINE_DLNA_SERVICE_H

#include <cstdio>
#include <string.h>
#include "iremote_proxy.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "system_ability_definition.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "hilog/log.h"
#include "ui/rs_surface_node.h"
#include "window.h"
#include "surface_utils.h"
#include "cast_engine_dlna_service_proxy.h"
#include "napi_remote_object.h"
#include "cast_engine_log.h"

namespace OHOS {
namespace CastEngine {
namespace CastEngineClient {
struct ResgisterDlnaPlayerData {
    napi_async_work asyncWork = nullptr;
    napi_deferred deferred = nullptr;
    napi_ref callback = nullptr;
    OHOS::sptr<OHOS::IRemoteObject> object = nullptr;
    int result;
    int cmd;
};

napi_value Play(napi_env env, napi_callback_info info);
napi_value Pause(napi_env env, napi_callback_info info);
napi_value Stop(napi_env env, napi_callback_info info);
napi_value Forward(napi_env env, napi_callback_info info);
napi_value Backward(napi_env env, napi_callback_info info);
napi_value GetPosition(napi_env env, napi_callback_info info);
napi_value GetPlayerStatus(napi_env env, napi_callback_info info);
napi_value GetDuration(napi_env env, napi_callback_info info);
napi_value Seek(napi_env env, napi_callback_info info);
napi_value SetSurfaceId(napi_env env, napi_callback_info info);
napi_value ResgisterDlnaPlayerAsync(napi_env env, napi_callback_info info);
napi_value GetDlnaDeviceName(napi_env env, napi_callback_info info);
napi_value SetDlnaDeviceName(napi_env env, napi_callback_info info);
napi_value GetDmrState(napi_env env, napi_callback_info info);
napi_value RegisterRemoteDiedListener(napi_env env, napi_callback_info info);
napi_value GetVolume(napi_env env, napi_callback_info info);
napi_value SetVolume(napi_env env, napi_callback_info info);
napi_value AuthDeviceFail(napi_env env, napi_callback_info info);

sptr<CastEngineService::ICastEngineDlnaService> GetAdaptor();
int SendDmrPlayer(const sptr<IRemoteObject> & object);
void ResgisterDlnaPlayerAsyncExecuteCB(napi_env env, void *data);
void ResgisterDlnaPlayerAsyncCallbackCompleteCB(napi_env env, napi_status status, void *data);
void ResgisterDlnaPlayerAsyncPromiseCompleteCB(napi_env env, napi_status status, void *data);

} // namespace CastEngineClient
} // namespace CastEngine
} // namespace OHOS

#endif // NAPI_CAST_ENGINE_DLNA_SERVICE_H